package net.mcreator.infinite_storage.procedure;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.Entity;

import net.mcreator.infinite_storage.ElementsInfiniteStorageMod;

import java.util.Map;
import java.util.HashMap;

@ElementsInfiniteStorageMod.ModElement.Tag
public class ProcedureInfiniteBagLevelUp extends ElementsInfiniteStorageMod.ModElement {
	public ProcedureInfiniteBagLevelUp(ElementsInfiniteStorageMod instance) {
		super(instance, 60);
	}
	static Map<String, Object> $_dependencies = new HashMap<>();
	public static void executeProcedure(Map<String, Object> dependencies) {
		if (dependencies.get("entity") == null) {
			return;
		}
		Entity entity = (Entity) dependencies.get("entity");
		NBTTagCompound InfiniteBag = entity.getEntityData().getCompoundTag("InfiniteBag");
		int NumTemp = ((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).experienceLevel : 0);
		if ((NumTemp >= InfiniteBag.getDouble("needLevel"))) {
			if (entity instanceof EntityPlayer)
				((EntityPlayer) entity).addExperienceLevel(-((int) InfiniteBag.getDouble("needLevel")));
			InfiniteBag.setDouble("InfiniteBagPageAdd", (InfiniteBag.getDouble("InfiniteBagPageAdd") + 1));
			InfiniteBag.setString("InfiniteBagTip", "\u00A7a\u5347\u7EA7\u6210\u529F");
		} else {
			InfiniteBag.setString("InfiniteBagTip", "\u00A7c\u7B49\u7EA7\u4E0D\u8DB3");
		}
		InfiniteBag.setDouble("InfiniteBagTipClear", 0);
		entity.getEntityData().setTag("InfiniteBag", InfiniteBag);
	}
}
